<template>
    <el-form-item label="发布时间" prop="name" :rules="{required: true, message: '请输入', trigger: ['blur', 'change']}" class="mt_20">
        <el-radio-group v-model="radio" @change="selectTime">
            <el-radio :label="1">立即发布</el-radio>
            <el-radio :label="2">定时发布</el-radio>
        </el-radio-group>
        <div class="mt_12" v-if="radio==2">
            <el-date-picker :clearable="false" v-model="subFrom.execution_time" value-format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择日期时间" :picker-options="pickerOptions">
            </el-date-picker>
        </div>
    </el-form-item>
</template>

<script>
export default {
    props: ["subFrom"],
    components: {},
    name: "",
    data() {
        return {
            radio: 1,
            pickerOptions: {
                disabledDate(time) {
                    return time.getTime() < Date.now() - 8.64e7; //如果没有后面的-8.64e7就是不可以选择今天的
                },
            },
        };
    },
    created() {},
    methods: {
        selectTime(val){
            let start_date = this.dayjs().format("YYYY-MM-DD HH:mm:ss");
            if(val==1){
                this.subFrom.execution_time = ""
            }else{
                this.subFrom.execution_time = start_date
            }
        }
    },
};
</script>


<style scoped>
.now_time {
    font-size: 14px;
    margin-left: 12px;
}
</style>

